package com.qdlc.p2p.biz.processor.task;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.qdlc.p2p.biz.processor.event.BorrowValueEvent;
import com.qdlc.p2p.biz.service.borrow.BorrowFullVerifyService;
import com.qdlc.p2p.common.core.queue.TaskProcessorException;
import com.qdlc.p2p.common.core.queue.ValueEvent;
import com.qdlc.p2p.dal.model.BorrowModel;


/**
 * 满标复审成功处理
 *
 * @author zhaokaiju
 */
@Service
public class VerifyFullSuccessTaskProcessor extends AbstractTaskProcessor {

	private static final Logger logger = Logger.getLogger(VerifyFullSuccessTaskProcessor.class);

	@Resource
	BorrowFullVerifyService borrowFullVerifyService;

	@Override
	public boolean supports(ValueEvent event) {
		return event instanceof BorrowValueEvent;
	}

	@Override
	protected void process0(ValueEvent event) throws TaskProcessorException {
		BorrowValueEvent borrowEvent = (BorrowValueEvent)event;
		BorrowModel borrowModel = borrowEvent.getBorrowModel();
		logger.info("++++ 满标复审通过,进入异步处理业务逻辑,borrowId:"+ borrowModel.getId());
        try {
			borrowFullVerifyService.verifyFullSuccess(borrowModel);
        } catch (Exception e) {
            logger.error("++++ 满标复审通过,进入异步处理业务逻辑异常,borrowId:"+ borrowModel.getId());
            throw new TaskProcessorException(borrowEvent, e);
        }
	}
}
